// src/renderer/main.js

import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import ElementPlus from 'element-plus';
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import 'element-plus/dist/index.css'
import './assets/element-variables.scss'

import Echarts from 'vue-echarts'
import * as echarts from 'echarts'

// 添加渲染进程错误捕捉
window.addEventListener('error', (event) => {
  console.error('渲染进程错误:', event.error);
  console.error('错误堆栈:', event.error?.stack);
});

window.addEventListener('unhandledrejection', (event) => {
  console.error('渲染进程未处理的Promise拒绝:', event.reason);
});

const app = createApp(App)

// 注册 Pinia 状态管理 [cite: 9]
app.use(createPinia())
// 注册路由
app.use(router)
// echarts
app.component('e-charts', Echarts)
app.config.globalProperties.$echarts = echarts

// element-plus
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(ElementPlus, {
	size: 'large'
})

app.mount('#app')